/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.apps.core;

import com.apps.beans.AccountBean;
import com.apps.ui.About;
import com.apps.ui.AccountSetupScreen;
import com.apps.ui.MainScreen;
import com.apps.ui.Settings;
import com.apps.ui.StatusScreen;
import com.apps.utils.StartupHelper;
import java.util.ArrayList;
import javax.swing.UIManager;

/**
 *
 * @author arijitpal
 */
public class Startup {
    /*
     * 1.Check for Current ENV
     * 2.Extract Acc List
     * 3.Open shell for all Acc
     * 4.Initiate status checker
     * 5.Load main UI
     * 
     */
    String currentEnvCode;
    ArrayList<AccountBean> accountList;
    StatusScreen statusUI;
    static MainScreen mainUI;
    
    public String getCurrentEnv(){
        return (currentEnvCode=StartupHelper.getSettings().getApps_env_code());
    }
    public ArrayList<AccountBean> getAccList(String envCode){
        return (accountList=StartupHelper.getAccList(envCode));
    }
    public void openAllShell(String envCode){
        StartupHelper.doEnvStartup(envCode);
    }
    public void initiateStatusChecker(){
        StatusScreen ss = new StatusScreen();
        statusUI = ss;
    }
    public void startUI()throws Exception{
        Settings settingsUI = new Settings();
        AccountSetupScreen accUI = new AccountSetupScreen();
        About aboutUI = new About();
        initiateStatusChecker();
        Startup.mainUI = new MainScreen();
        mainUI.setAboutUI(aboutUI);
        mainUI.setAccUI(accUI);
        mainUI.setSettingsUI(settingsUI);
        mainUI.setStatusUI(statusUI);
        
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try{
                    UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
                }catch(Exception ex){ ex.printStackTrace();}
                try{
                    mainUI.setVisible(true);
                }catch(Exception ex){ex.printStackTrace();}
            }
        });
        
    }
    
}
